import request from "@/utils/request";

//1.获取品牌列表数据的请求
/**@reqTrademarkListParamsType 品牌列表请求参数的类型*/
export interface reqTrademarkListParamsType {
  page: number;
  limit: number;
}

/**@trademarkRecordsItemType 品牌列表每一项的类型*/
export interface trademarkRecordsItemType extends reqAddTrademarkParamsType {
  id: number;
}

/**@trademarkRecordsListType 品牌列表类型*/
export type trademarkRecordsListType = trademarkRecordsItemType[];

/**@reqTrademarkListReturnType 品牌列表返回值的的类型 */
export interface reqTrademarkListReturnType {
  records: trademarkRecordsListType;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}

/**@requestTrademarkList 品牌列表的请求api */
export const requestTrademarkList = ({
                                       page,
                                       limit
                                     }: reqTrademarkListParamsType) => {
  return request.get<any, reqTrademarkListReturnType>(
    `/admin/product/baseTrademark/${page}/${limit}`
  );
};

//2.品牌添加的请求
/**@reqAddTrademarkParamsType 添加品牌的类型参数类型 */
export interface reqAddTrademarkParamsType {
  tmName: string;
  logoUrl: string;
}

/**@requestAddTrademark 添加品牌的请求api */
export const requestAddTrademark = (trademark: reqAddTrademarkParamsType) => {
  return request.post<any, null>(
    `/admin/product/baseTrademark/save`,
    trademark
  );
};

//3.品牌修改的请求
/**@requestUpdateTrademark 更新品牌的请求api */
export const requestUpdateTrademark = (trademark: trademarkRecordsItemType) => {
  return request.put<any, null>(
    `/admin/product/baseTrademark/update`,
    trademark
  );
};

//4.品牌删除的请求
/**@requestDeleteTrademark 删除品牌的请求api */
export const requestDeleteTrademark = (id: number) => {
  return request.delete<any, null>(`/admin/product/baseTrademark/remove/${id}`);
};

//5.获取所有品牌的请求
/**@requestAllTrademarkList 获取所有品牌的请求api */
export const requestAllTrademarkList = () => {
  return request.get<any, trademarkRecordsListType>(
    `/admin/product/baseTrademark/getTrademarkList`
  );
};